package ThreadDemo;
import java.util.concurrent.Semaphore;
public class ThreadDemo {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore = new Semaphore(1);//可用资源量是4个
        semaphore.acquire(1);
        System.out.println("1");//申请,计数值加1
        semaphore.acquire(1);
        System.out.println("1");
        semaphore.release();
        System.out.println("2");

    }
}
